<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>05rem单位</title>
    <style>
        html {
            font-size: 15px;
        }
        
        div {
            font-size: 10px;
        }
        
        p {
            /* em单位相对于父元素字体大小，所以2em为20px */
            /* width: 2em;
            height: 2em; */
            /* rem的基准是相对于html元素的字体大小,所以此例2rem为30px */
            width: 2rem;
            height: 2rem;
            background-color: hotpink;
        }
    </style>
</head>

<body>
    <div>
        <p></p>
    </div>
</body>

</html>